import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 递归求和
 * User: 15085202591
 * Date: 2022-11-03
 * Time: 18:39
 */
public class Sum {
    public static int Sum(int x){
        if (x == 1){
            return 1;
        }else {
            return x+Sum(x-1);
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("输入数字：");
        while (sc.hasNextInt()){
            int n = sc.nextInt();
            System.out.println("和为"+Sum(n));
            System.out.print("输入数字：");
        }
    }
}
